<template>
	<view>
		<view >{{date2}}</view>
	</view>
</template>

<script>
	export default {
		name: "my-time",
		data() {
			return {
				//定时器
				setTime:'',
				date:'',
				date2:''

			};
		},
		onShow() {
			this.getnewtime()
		},
		
		
		methods: {
			getnewtime() {
				var setTime = setInterval(() => {
					let date = new Date()
					let year = date.getFullYear()
					let month = date.getMonth() + 1
					month >= 9 ? month : month = '0' + month
					let day = date.getDate()
					day >= 9 ? day : day = '0' + day
					let hour = date.getHours()
					hour >= 9 ? hour : hour = '0' + hour
					let minute = date.getMinutes()
					minute >= 9 ? minute : minute = '0' + minute
					let second = date.getSeconds()
					second >= 9 ? second : second = '0' + second
					this.date = year + '-' + month + '-' + day + "  " + hour + ":" + minute + ":" + second
					this.date2 =  hour + ":" + minute + ":" + second
				}, 1000)
                console.log(this.date);
			}

		}
	}
</script>

<style lang="scss">

</style>
